<?php

	include_once("./dal/CountryDAL.php");
	
	function renderAllCountryOptions($selectedCountry, $selectedCountryID)
	{
		$countries = getAllCountries();
		
		if($countries!=null)
		{
			if(is_array($countries))
			{
				$countryCount = count($countries);
				
				echo '<option value="'.'0'.'">'.'Choose a Country'.'</option>';
				
				foreach($countries as $country)
				{
					if(is_null($selectedCountryID) || empty($selectedCountryID))
					{
						if(strcasecmp($selectedCountry,$country["iso_alpha_3"])==0)
						{
							echo '<option value="'.$country["country_id"].'" selected>'. utf8_encode($country["country_name"]).'</option>';
						}
						else
						{
							echo '<option value="'.$country["country_id"].'">'.utf8_encode($country["country_name"]).'</option>';
						}
					}
					else
					{
						if(strcasecmp($selectedCountryID,$country["country_id"])==0)
						{
							echo '<option value="'.$country["country_id"].'" selected>'. utf8_encode($country["country_name"]).'</option>';
						}
						else
						{
							echo '<option value="'.$country["country_id"].'">'.utf8_encode($country["country_name"]).'</option>';
						}
					}
				}
				
			}
		}
	}
	
	function renderAlertControl($type, $heading, $msg)
	{
		$control = <<<EOT
<div class="alert alert-%s">
	<a class="close" data-dismiss="alert" href="#">x</a>
	<h4 class="alert-heading" id="h4Heading" runat="server">
		%s
	</h4>
	%s
</div>
EOT;
		
		$control = sprintf($control, $type, $heading, $msg); 
		
		return $control;
	}
	
?>